import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2025-08-19
 * Time: 10:21
 */
public class demo3 {
    public static void main(String[] args) {
        Object locker = new Object();

        Thread t1 = new Thread(() -> {
            try{
                System.out.println("wait 之前");
                synchronized(locker){
                    locker.wait();
                }
                System.out.println("wait 之后");
            }catch (InterruptedException e){
                throw new RuntimeException();
            }
        });

        Thread t2 = new Thread(() -> {
                Scanner scanner = new Scanner(System.in);
                System.out.println("输入 释放locker");
                scanner.next();
               synchronized(locker){
                   locker.notify();
               }
        });

        t1.start();
        t2.start();
    }
}
